package com.ruoyi.system.service.honor.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.honor.studentedupaper.StudentEduPaper;
import com.ruoyi.system.mapper.honor.StudentEduPaperMapper;
import com.ruoyi.system.service.honor.IStudentEduPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.ruoyi.common.utils.SecurityUtils.getUserId;

/**
 * 学生优秀毕业论文Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-11
 */
@Service
public class StudentEduPaperServiceImpl implements IStudentEduPaperService
{
    @Autowired
    private StudentEduPaperMapper studentEduPaperMapper;

    /**
     * 查询学生优秀毕业论文
     * 
     * @param id 学生优秀毕业论文主键
     * @return 学生优秀毕业论文
     */
    @Override
    public StudentEduPaper selectStudentEduPaperById(Long id)
    {
        return studentEduPaperMapper.selectStudentEduPaperById(id);
    }

    /**
     * 查询学生优秀毕业论文列表
     * 
     * @param studentEduPaper 学生优秀毕业论文
     * @return 学生优秀毕业论文
     */
    @Override
    public List<StudentEduPaper> selectStudentEduPaperList(StudentEduPaper studentEduPaper)
    {
        //如果是老师，则只显示自己上传的
        if(studentEduPaper.getCurrentRole()!=null&&studentEduPaper.getCurrentRole().equals("teacher")){
            studentEduPaper.setTeacherId(String.valueOf(getUserId()));
        }
        //如果是部门，则显示老师是系里的所有
        if(studentEduPaper.getCurrentRole()!=null&&studentEduPaper.getCurrentRole().equals("department")){
            studentEduPaper.setDeptId(SecurityUtils.getDeptId());
        }
        return studentEduPaperMapper.selectStudentEduPaperList(studentEduPaper);
    }

    /**
     * 新增学生优秀毕业论文
     * 
     * @param studentEduPaper 学生优秀毕业论文
     * @return 结果
     */
    @Override
    public int insertStudentEduPaper(StudentEduPaper studentEduPaper)
    {
        return studentEduPaperMapper.insertStudentEduPaper(studentEduPaper);
    }

    /**
     * 修改学生优秀毕业论文
     * 
     * @param studentEduPaper 学生优秀毕业论文
     * @return 结果
     */
    @Override
    public int updateStudentEduPaper(StudentEduPaper studentEduPaper)
    {
        return studentEduPaperMapper.updateStudentEduPaper(studentEduPaper);
    }

    /**
     * 批量删除学生优秀毕业论文
     * 
     * @param ids 需要删除的学生优秀毕业论文主键
     * @return 结果
     */
    @Override
    public int deleteStudentEduPaperByIds(Long[] ids)
    {
        return studentEduPaperMapper.deleteStudentEduPaperByIds(ids);
    }

    /**
     * 删除学生优秀毕业论文信息
     * 
     * @param id 学生优秀毕业论文主键
     * @return 结果
     */
    @Override
    public int deleteStudentEduPaperById(Long id)
    {
        return studentEduPaperMapper.deleteStudentEduPaperById(id);
    }
}
